home *** CD-ROM | disk | FTP | other *** search
/ Night Owl 6 / Night Owl's Shareware - PDSI-006 - Night Owl Corp (1990).iso / 039a / dflat8.zip / STATBAR.C < prev    next >
Text File  |  1991-09-30  |  1KB  |  58 lines

  1. /* ---------------- statbar.c -------------- */
  2.  
  3. #include "dflat.h"
  4.  
  5. int StatusBarProc(WINDOW wnd, MESSAGE msg, PARAM p1, PARAM p2)
  6. {
  7.     char *statusbar;
  8.     switch (msg)    {
  9.         case CREATE_WINDOW:
  10.         case MOVE:
  11.             SendMessage(wnd, CAPTURE_CLOCK, 0, 0);
  12.             break;
  13.         case KEYBOARD:
  14.             if ((int)p1 == CTRL_F4)
  15.                 return TRUE;
  16.             break;
  17.         case PAINT:    
  18.             if (!isVisible(wnd))
  19.                 break;
  20.             if ((statusbar = calloc(1, WindowWidth(wnd)+1)) == NULL)
  21.                 break;
  22.             memset(statusbar, ' ', WindowWidth(wnd));
  23.             *(statusbar+WindowWidth(wnd)) = '\0';
  24.             strncpy(statusbar+1, "F1=Help", 7);
  25.             if (wnd->text)    {
  26.                 int len = min(strlen(wnd->text), WindowWidth(wnd)-17);
  27.                 if (len > 0)    {
  28.                     int off=(WindowWidth(wnd)-len)/2;
  29.                     strncpy(statusbar+off, wnd->text, len);
  30.                 }
  31.             }
  32.             if (wnd->TimePosted)
  33.                 *(statusbar+WindowWidth(wnd)-8) = '\0';
  34.             SetStandardColor(wnd);
  35.             wputs(wnd, statusbar, 0, 0);
  36.             free(statusbar);
  37.             return TRUE;
  38.         case BORDER:
  39.             return TRUE;
  40.         case CLOCKTICK:
  41.             SetStandardColor(wnd);
  42.             wputs(wnd, (char *)p1, WindowWidth(wnd)-8, 0);
  43.             wnd->TimePosted = TRUE;
  44.             return TRUE;
  45.         case CLOSE_WINDOW:
  46.             SendMessage(NULL, RELEASE_CLOCK, 0, 0);
  47.             if (GetText(wnd) != NULL)    {
  48.                 free(GetText(wnd));
  49.                 GetText(wnd) = NULL;
  50.             }
  51.             break;
  52.         default:
  53.             break;
  54.     }
  55.     return BaseWndProc(STATUSBAR, wnd, msg, p1, p2);
  56. }
  57.  
  58.